#!/home/kjirou/local/bin/ruby

begin
    require "etc/config.rb"
    require "cgi"
    cgi = CGI.new

    case cgi["src_name"]
    when "frame.js"
        print cgi.header({"type" => "application/x-javascript"})
        print File::open($JS_DIR + "frame.js").read().gsub(/\{\*\$WWW_BASE_DIR\*\}/, $WWW_BASE_DIR);
    when "iframe.html"
        obm_js = $WWW_BASE_DIR + 'get_src.cgi?src_name=obm.js&' + Time.now.strftime("%Y%m%d%H%M%S")
        print cgi.header({"type" => "text/html"})
        print File::open($JS_DIR + "iframe.html").read().gsub(/\{\*obm\.js\*\}/, obm_js);
    when "obm.js"
        print cgi.header({"type" => "application/x-javascript"})
        print File::open($JS_DIR + "obm.js").read().gsub(/\{\*\$WWW_BASE_DIR\*\}/, $WWW_BASE_DIR);
    else
        print cgi.header({"type" => "text/plain"})
    end
rescue
    print $! , "\n", $@
end

